/**********************************
 * @Author: Qi Hang
 * @LastEditor: Qi Hang
 * @LastEditTime: 20:23:59, 星期日 18, 五月 2025
 * @Email: wqwzxwzx@gmail.com
 * Copyright © 2023 Qi Hang | https://hanghang.xyz
 **********************************/

import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
import { basicRoutes } from "./basic-routes";
import { setupRouterGuards } from "./guards";

export const router = createRouter({
  history:
    import.meta.env.VITE_USE_HASH === "true"
      ? createWebHashHistory(import.meta.env.VITE_PUBLIC_PATH || "/")
      : createWebHistory(import.meta.env.VITE_PUBLIC_PATH || "/"),
  routes: basicRoutes,
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

export async function setupRouter(app) {
  app.use(router);
  setupRouterGuards(router);
}
